package com.hd.pzhwlxt.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hd.pzhwlxt.pojo.VehicleRepairInfo;
import com.hd.pzhwlxt.service.VehicleRepairInfoService;
import com.hd.pzhwlxt.utils.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @create: 2022-09-21 9:03
 * @author: 怀念天空
 * @Description: 车辆维修记录
 */
@RestController
@RequestMapping("/vehiclRepair")
public class VehicleRepairController {

    @Autowired
    private VehicleRepairInfoService vehicleRepairInfoService;

    /**
     * 获取所有的维修记录，包括维修工信息和车辆具体信息
     * @return
     */
    @GetMapping("/get")
    public Response<Page<VehicleRepairInfo>> getAllVehiclRepairInfo(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize",defaultValue = "4") Integer pageSize){
        Page<VehicleRepairInfo> pageInfo = vehicleRepairInfoService.getVehicleAndWokerInfo(pageNum, pageSize);
        if (pageInfo!=null){
            return Response.createSuccessResponse("查询成功",pageInfo);
        }
        return Response.createErrorResponse("查询失败");
    }
}
